﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EMR.GeneralManager
{
    public partial class DBFForm : Form
    {
        public DBFForm()
        {
            InitializeComponent();
        }

        private void btnExp_Click(object sender, EventArgs e)
        {
            ExportDBF eDBF = new ExportDBF();
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "选择dBase IV文件保存的文件夹";
            fbd.SelectedPath = System.Environment.CurrentDirectory;
            fbd.ShowNewFolderButton = true;
            string mTableName = "JuNanZBData";
            try
            {
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    if (System.IO.File.Exists(fbd.SelectedPath + "\\" + mTableName + ".dbf") == true)
                    {
                        System.IO.File.Delete(fbd.SelectedPath + "\\" + mTableName + ".dbf");
                    }

                    if (eDBF.Create(fbd.SelectedPath, mTableName + ".dbf"))//创建文件成功
                    {
                        eDBF.SaveDBF(fbd.SelectedPath, this.dateTimePickerFrom.Value, this.dateTimePickerTo.Value);
                        MessageBox.Show("恭喜，导出成功！");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
